package com.junxonline.instant.job.service.config.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junxonline.instant.common.constant.DataSourceConstant;
import com.junxonline.instant.dao.entity.model.config.DataSource;
import com.junxonline.instant.dao.mapper.config.DataSourceMapper;
import com.junxonline.instant.job.service.config.DataSourceService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 数据源管理接口实现类
 *
 * @author JunX
 * @date 2021-08-02
 */
@Log4j2
@Service
@Transactional
public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSource> implements DataSourceService {

    @Autowired
    private DataSourceMapper dataSourceMapper;

    /**
     * 创建表
     *
     * @param sqlList SQL语句集合
     */
    @Override
    @DS(DataSourceConstant.SHARDING)
    public void createTable(List<String> sqlList) {
        dataSourceMapper.createTable(sqlList);
    }

}
